package com.ruitu.mall_98_1.mvp.model;

import com.ruitu.mall_98_1.dao.api.APIRetrofit;
import com.ruitu.mall_98_1.mvp.contract.ProductDetailContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.product.ProDetail;
import com.ruitu.router_module.bean.product.SpecInfo;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/11/06
 */
public class ProductDetailModelImpl implements ProductDetailContract.Model {

    @Override
    public Observable<BaseResult<ProDetail>> reqProDetail(String goodId, String accountId) {
        return APIRetrofit.getDefault().reqProDetial(goodId, accountId)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult<SpecInfo>> reqProSpec(String goodId) {
        return APIRetrofit.getDefault().reqProSpec(goodId)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult> addToCart(String goodsId, String accountId, int num, String skuId) {
        return APIRetrofit.getDefault().addToCart(goodsId, accountId, num, skuId)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult> reqGetCoupon(String accountId, String couponId) {
        return APIRetrofit.getDefault().reqGetCoupon(accountId, couponId)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult> reqcollect(String accountId, String type, String infoId) {
        return APIRetrofit.getDefault().reqCollect(accountId, type, infoId)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult> reqcollectCancel(String accountId, String type, String id) {
        return APIRetrofit.getDefault().reqCollectCancel(accountId, type, id)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }
}